package cool.taomu.web.utils

import java.util.List
import java.util.stream.Collectors

class ListPageUtils {
	static interface Result<T>{
		def void data(int index,T result)
	}
	def static <T> page(int pageNo,int pageSize, List<T> datas,Result<T> res) {
		if (!datas.isNullOrEmpty) {
			var lists = datas.stream.skip((pageNo-1)*pageSize).limit(pageSize).collect(Collectors.toList);
			for(var i=0;i<lists.size;i++){
				res.data(pageNo,lists.get(i));
			}
		}
	}
}
